package server

import (
	"bufio"
	"github.com/akirakazu/log4go"
	"net"
	"os"
	"path/filepath"
	"strings"
)

func (s *Server) initBinDir() {
	binDir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
	s.binDir = binDir
}

func (s *Server) initCert() {
	// SSL cert and key file location
	cert := filepath.Join(s.binDir, "./cert.pem")
	key := filepath.Join(s.binDir, "./key.pem")

	_, certErr := os.Stat(cert)
	_, keyErr := os.Stat(key)
	if certErr != nil || keyErr != nil {
		GenerateCert(cert, key)
	}
	s.cert = cert
	s.key = key
}
